package com.hq.door.controller;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hq.door.dto.OutrequestInfo;
import com.hq.door.dto.TRecordInfo;
import com.hq.door.dto.Teacher;
import com.hq.door.pojo.TRecords;
import com.hq.door.service.TRecordsService;

@Controller
@RequestMapping("/trecords")
public class TRecordsController {
	@Autowired
	TRecordsService tRecordsService;

	@RequestMapping("/showrecords")
	@ResponseBody
	public Object showmation(
			@RequestParam(value = "type", required = false) Integer type,
			@RequestParam(value = "para", required = true) String[] para,
			@RequestParam(value = "pageSize", required = false) Integer pageSize,
			@RequestParam(value = "pageStart", required = false) Integer pageStart) {

		List<TRecordInfo> infos = null;
		if (pageSize != null && pageStart != null) {
			infos = tRecordsService.showAll(type, para, pageStart, pageSize);
		} else {
			return tRecordsService.getCount(type, para);
		}
		return infos;
	}
	
	@RequestMapping("excelExport")
	public void excelExport(@RequestParam(value = "para", required = true) String[] para,HttpServletResponse response){
		List<TRecordInfo> infos = null;
		Integer type = 0;
		Integer pageSize = 100000000;
		Integer pageStart = 0;
		infos = tRecordsService.showAll(type, para,pageStart,pageSize);
		tRecordsService.excelExport(infos,response);
	}
}
